package com.risetechnology.services.appservices;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.widget.Toast;

public class CountDownManager implements ServiceConnection {
	/*
	 * field
	 */
	private CountDownService mService=null;
	private Context context;
	
	/**
	 * 
	 * @param context
	 */
	public CountDownManager(Context context) {
		this.context=context;
		
		if(mService==null) this.context.bindService(new Intent(this.context,CountDownService.class), this, Context.BIND_AUTO_CREATE);
		
	}
	

	public void onCDT1Tick(long remaining){
		remaining = getCurTime1();
	}
	
	public void onCDT2Tick(long remaining){
		remaining = getCurTime2();
	}
	
	public void onCDT3Tick(long remaining){
		remaining = getCurTime3();
	}
	
	public void onCDT1Finish(){}
	public void onCDT2Finish(){}
	public void onCDT3Finish(){}
	
	public void onServiceConnected(ComponentName name, IBinder service) {
		mService = ((CountDownServiceBinder)service).getService();
	}

	public void onServiceDisconnected(ComponentName name) {
		mService=null;
	};
	/*
	 * public method
	 */
	
	
	public boolean isPlaying(){
		return mService.isPlaying();
	}
	
	public void checkReadyToPlay(){
		mService.checkReadyToPlay();
	}
	
	/**
	 * @return the curTime1
	 */
	public long getCurTime1() {
		return mService.getCurTime1();
	}

	/**
	 * @param curTime1 the curTime1 to set
	 */
	public void setCurTime1(long curTime1) {
		mService.setCurTime1(curTime1);
	}

	/**
	 * @return the curTime2
	 */
	public long getCurTime2() {
		return mService.getCurTime2();
	}

	/**
	 * @param curTime2 the curTime2 to set
	 */
	public void setCurTime2(long curTime2) {
		mService.setCurTime2(curTime2);
	}

	/**
	 * @return the curTime3
	 */
	public long getCurTime3() {
		return mService.getCurTime3();
	}

	/**
	 * @param curTime3 the curTime3 to set
	 */
	public void setCurTime3(long curTime3) {
		mService.setCurTime3(curTime3);
	}

	/**
	 * @return the recipeID1
	 */
	public int getRecipeID() {
		return mService.getRecipeID();
	}

	/**
	 * @param recipeID1 the recipeID1 to set
	 */
	public void setRecipeID(int recipeID) {
		mService.setRecipeID(recipeID);
	}

	/**
	 * @return the lastRecipeID1
	 */
	public int getLastRecipeID1() {
		return mService.getLastRecipeID1();
	}

	/**
	 * @param lastRecipeID1 the lastRecipeID1 to set
	 */
	public void setLastRecipeID1(int lastRecipeID1) {
		mService.setLastRecipeID1(lastRecipeID1);
	}

	/**
	 * @return the lastRecipeID2
	 */
	public int getLastRecipeID2() {
		return mService.getLastRecipeID2();
	}

	/**
	 * @param lastRecipeID2 the lastRecipeID2 to set
	 */
	public void setLastRecipeID2(int lastRecipeID2) {
		mService.setLastRecipeID2(lastRecipeID2);
	}

	/**
	 * @return the lastRecipeID3
	 */
	public int getLastRecipeID3() {
		return mService.getLastRecipeID3();
	}

	/**
	 * @param lastRecipeID3 the lastRecipeID3 to set
	 */
	public void setLastRecipeID3(int lastRecipeID3) {
		mService.setLastRecipeID3(lastRecipeID3);
	}
	
	public void updateCDT1(long time){
		mService.updateCDT1(time);
	}
	
	public void updateCDT2(long time){
		mService.updateCDT2(time);
	}
	
	public void updateCDT3(long time){
		mService.updateCDT3(time);
	}
	
	/**
	 * @return the ready1
	 */
	public boolean isReady1() {
		return mService.isReady1();
	}

	/**
	 * @param ready1 the ready1 to set
	 */
	public void setReady1(boolean ready1) {
		mService.setReady1(ready1);
	}

	/**
	 * @return the ready2
	 */
	public boolean isReady2() {
		return mService.isReady2();
	}

	/**
	 * @param ready2 the ready2 to set
	 */
	public void setReady2(boolean ready2) {
		mService.setReady2(ready2);
	}

	/**
	 * @return the ready3
	 */
	public boolean isReady3() {
		return mService.isReady3();
	}

	/**
	 * @param ready3 the ready3 to set
	 */
	public void setReady3(boolean ready3) {
		mService.setReady3(ready3);
	}
	
	public void playRecord(int pos){
		mService.playRecord(pos);
	}
	
	/**
	 * @return the recording
	 */
	public boolean isRecording() {
		return mService.isRecording();
	}

	/**
	 * @param recording the recording to set
	 */
	public void setRecording(boolean recording) {
		mService.setRecording(recording);
	}
	
	/**
	 * @return the selected1
	 */
	public boolean isSelected1() {
		return mService.isSelected1();
	}

	/**
	 * @return the selected2
	 */
	public boolean isSelected2() {
		return mService.isSelected2();
	}

	/**
	 * @return the selected3
	 */
	public boolean isSelected3() {
		return mService.isSelected3();
	}
	
	/**
	 * @param filePath1 the filePath1 to set
	 */
	public void setFilePath1(String filePath1) {
		mService.setFilePath1(filePath1);
	}

	/**
	 * @param filePath2 the filePath2 to set
	 */
	public void setFilePath2(String filePath2) {
		mService.setFilePath2(filePath2);
	}

	/**
	 * @param filePath3 the filePath3 to set
	 */
	public void setFilePath3(String filePath3) {
		mService.setFilePath3(filePath3);
	}
	
	/**
	 * @param selected1 the selected1 to set
	 */
	public void setSelected1(boolean selected1) {
		mService.setSelected1(selected1);
	}

	/**
	 * @param selected2 the selected2 to set
	 */
	public void setSelected2(boolean selected2) {
		mService.setSelected2(selected2);
	}

	/**
	 * @param selected3 the selected3 to set
	 */
	public void setSelected3(boolean selected3) {
		mService.setSelected3(selected3);
	}
}
